package com.gitee.wsl.doc.prosemirror.model.node

import com.gitee.wsl.doc.prosemirror.model.attr.Attrs
import com.gitee.wsl.doc.prosemirror.model.fragment.Fragment
import com.gitee.wsl.doc.prosemirror.model.mark.Mark

// To be type safe every NodeType should be created through create method. Otherwise it would be
// of generic type Node
interface NodeCreator<T : Node> {
    fun create(type: NodeType, attrs: Attrs, content: Fragment? = null, marks: List<Mark> = Mark.none): T

    companion object {
        internal val DEFAULT = object : NodeCreator<Node> {
            override fun create(type: NodeType, attrs: Attrs, content: Fragment?, marks: List<Mark>): Node {
                return Node(type, attrs, content, marks)
            }
        }
    }
}